# -*- coding: utf-8 -*-
"""
@Time: 2022/3/14 19:53
@Author: jins
@File: helperFiction.py
@Introduction: 
"""
from common.requests_api import auto_request


def to_str(bytes_or_str):
    """
    将二进制字符转换为str字符
    @param bytes_or_str: 需要转换的字符
    @return: 转换好的str字符
    """
    if isinstance(bytes_or_str, bytes):
        value = bytes_or_str.decode('utf-8')
    else:
        value = bytes_or_str
    return value


def to_bytes(bytes_or_str):
    """
    将str字符转化为二进制字符
    @param bytes_or_str: 需要转化的字符
    @return: 转化好的二进制字符
    """
    if isinstance(bytes_or_str, str):
        value = bytes_or_str.encode('utf-8')
    else:
        value = bytes_or_str
    return value


def get_token():
    res = auto_request(url='10.0.17.17:8099/sys/login', method='POST', body={
        "authType": "password",
        "envType": "prod",
        "username": "test_ld",
        "password": "e10adc3949ba59abbe56e057f20f883e",
        "sysCode": "os_web"
    })
    return res['data']['token']
